package com.info.zhiduoduo.repository.mapper.system;

import com.baomidou.mybatisplus.mapper.BaseMapper;
import com.info.zhiduoduo.repository.dto.system.GetSystemRoleDto;
import com.info.zhiduoduo.repository.entity.system.SystemRole;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

public interface RoleMapper extends BaseMapper<SystemRole> {


    /**
     * 校验角色
     * @param roleName
     * @return
     */
    @Select("select COUNT(*) from zdd_system_role where rolename = #{roleName}")
    int checkRole(@Param("roleName") String roleName);


    /**
     * 查看详情
     * @param roleid
     * @return
     */
    @Select("select zsr.*,GROUP_CONCAT(zsrm.menuid) as menuids from zdd_system_role zsr " +
            "LEFT JOIN zdd_system_rolemenu zsrm ON zsr.roleid = zsrm.roleid where zsr.roleid = #{roleid}")
    GetSystemRoleDto getSystemRoleById(@Param("roleid") int roleid);

}
